package com.andy.customerService.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 *  插入、更新 自动传时间参数
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    //插入时
    @Override
    public void insertFill(MetaObject metaObject) {
//        Integer userId = UserLocalUtil.getAuthUserId();
//        if (null == userId) {
//            userId = 1;
//        }
        this.setFieldValByName("createTime",new Date(),metaObject);
//        this.setFieldValByName("createBy",userId,metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
//        this.setFieldValByName("updateBy",userId,metaObject);
    }
    //更新时
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",new Date(),metaObject);
    }
}
